<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@taglib prefix="s" uri="/struts-tags"  %>
<%
	String operation = request.getParameter("operation");
%>
<%@ page import="com.starbaba.core.web.constant.WebConstants"%>
<%@ page import="com.starbaba.system.user.model.UserVO"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
.table>th {
	vertical-align: center;
	background-color: grey;
}
input[type="radio"] {
  margin-top:-2px; 
  margin-bottom:1px;
  margin-left: 2px;
  vertical-align:middle; 
}
</style>
</head>
<body class="no-skin">
	<div class="page-content">
		<div class="page-content-area">
			<div class="row">
				<div class="col-xs-12 col-sm-12 widget-container-col">
					<div class="widget-box widget-color-blue" style="height: 255px">
						<div class="widget-header widget-header-small">
							<h6 class="widget-title lighter">
								<i class="ace-icon glyphicon glyphicon-th-list"></i>操作
							</h6>
							<div class="widget-toolbar no-border">
								<a href="#" data-action="collapse"> <i
									class="ace-icon fa fa-chevron-up"></i>
								</a>
							</div>
						</div>

						<div class="widget-body">
							<div class="widget-main">
								<form class="form-horizontal" id="form1"
									name="form1" method="post">
									<input type="hidden" name="userid" value="${param.userid}" />
									<input type="hidden" name="operator" value="<%=((UserVO) session.getAttribute(WebConstants.SESSION_ATTRIBUTE_USER)).getUsername() %>"/>
									<table id="baseinfo"
										class="table table-bordered table-striped table-hover table-condensed table-responsive table">
										<tr>
											<th style="width: 100px">积分</th>
											<td colspan="7"><input type="text" name="value" id="value" class="col-xs-12 col-sm-4" />
											</td>
										</tr>
										<tr>
											<th style="width: 100px">产品类型</th>
											<td colspan="7">
											   <select class="form-control" name="prd_type">
												 <option value="1">菠萝贷</option>
												 <option value="2">微信菠萝贷</option>
												 <option value="3">香蕉还卡</option>
											   </select>
											</td>
										</tr>
										<tr>
											<th style="width: 100px">操作类型</th>
											<td colspan="7">
											   <input type="radio" name="type" value="1">增加积分
											   <input type="radio" name="type" value="2" checked>扣减积分
											</td>
										</tr>
										<tr>
											<th style="width: 100px">备注</th>
											<td colspan="7">
											   <input type="text" name="memo" id="memo" class="col-xs-12 col-sm-12">
											</td>
										</tr>
									</table>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn  btn-inverse  no-border " onclick="doCancle()"
						id="delete">
						<i class="ace-icon fa fa-undo bigger-160"></i> 取消
					</button>
					&nbsp; &nbsp; &nbsp;
					<button id="btn-save" name="btn-save"
						class="btn  btn-success  no-border" type="button"
						onclick="doSave()">
						<i class="ace-icon fa fa-floppy-o bigger-160"></i> 保存
					</button>
				</div>
			</div>
		</div>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<%@ include file="/discovery/maxlength.jsp"%>
	<script type="text/javascript" src="${ctx}/ace/js/maxlength.js"></script>
	<script type="text/javascript" src="${ctx}/js/wangEditor-1.3.11.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script>
		function doCancle() {
			try {
				if (parent) {
					parent.parent['__extdialog_active'].dialog('close');
				}
			} catch (e) {
				window.history.back();
			}
		}

		function doSave() {
			if ($.isBlank($("#value").val())) {
				parent.bootbox.alert("积分不能为空!");
				return;
			}
			if(isNaN($("#value").val())){
				parent.bootbox.alert("积分只能为数字");
				return;
			}
			if($("#value").val() <= 0){
				parent.bootbox.alert("积分必须大于零");
				return;
			}
			$("#btn-save").attr("disabled", "disabled");
			saveForm();
		}

		function saveForm() {
			var saveUrl = ctx + "/userpoint/save.action";
			var options = {
				url : saveUrl,
				type : "POST",
				dataType : "json",
				beforeSend : function() {
					$(".load_bg,.load_img").show();
				},
				success : function(data) {
					alert(data["result"]["msg"]);
					parent.parent['__extdialog_active'].dialog('close');
					parent.query_any();
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert(textStatus);
					console.log(XMLHttpRequest, textStatus, errorThrown);
				},
				complete : function() {
					$(".load_bg,.load_img").hide();
				}
			};
			$('form[name="form1"]').ajaxSubmit(options);
		}
	</script>
</body>
</html>
